class Solution10 {
    public int count = 0;
    public int ret = 0;
    public int kthSmallest(TreeNode root, int k) {
        count = k;
        difs(root);
        return ret;
    }

    public void difs(TreeNode root) {
        if(root == null || count == 0) return ;//剪枝
        difs(root.left);
        if(count == 0) return;//剪枝
        count--;
        if(count == 0) {
            ret = root.val;
            return;//剪枝
        }
        difs(root.right);
    }
}